#pragma once
#include"HashTable.h"

template<class K,class V,class Hash = HashFunc<K>>
class unorderedmap
{
	class KetOfTMap
	{
	public:
		const K& operator()(const pair<K,V>& kv)
		{
			return kv.first;
		}
	};
public:
	typedef typename HashTable<K,pair<const K, V>, KetOfTMap, Hash>::_iterator iterator;
	typedef typename HashTable<K,pair<const K, V>, KetOfTMap, Hash>::_const_iterator const_iterator;

	iterator begin()
	{
		return _ht.Begin();
	}

	const_iterator begin() const
	{
		return _ht.Begin();
	}

	iterator end()
	{
		return _ht.End();
	}

	const_iterator end() const
	{
		return _ht.End();
	}

	pair<iterator, bool> insert(const pair<K,V>& kv)
	{
		return _ht.Insert(kv);
	}

	iterator find(const K& key)
	{
		return _ht.Find(key);
	}

	bool erase(const K& key)
	{
		return _ht.Erase(key);
	}

	V& operator[](const K& key)
	{
		pair<iterator, bool> ret = insert({ key,V() });
		return ret.first->second;
	}

private:
	HashTable<K,pair<const K,V>, KetOfTMap, Hash> _ht;
};